Inaccessible Matching Constructors or Methods (IMCM)

Description:

IMCM checks that all of the overloaded constructors or methods that may be applicable to the same method or constuctor invocation have the same visibility.

Imagine that a client of class Printer is located in a different class than Printer. Then the allocation of Printer violates this rule, because the second constructor is not visible at the point of the allocation, but it still matches the allocation (based on signature). Also, the call to print violates this rule, because the second and third declarations of print are not visible at the point of the call, but they still match the call (based on the signature).

Incorrect:

public class Printer {
    public Printer(int queueSize) {
        ...
    }
	
    private Printer(char id) {
        ...
    }
    
    public void print(int value) {
        ...
    }
    
    private void print(short value) {
        ...
    }
    
    private void print(char value) {
        ...
    }
}

Printer printer = new Printer('a');
printer.print('\n');

Correct:

public class Printer {
    public Printer(int queueSize) {
        ...
    }
	
    public Printer(char id) {
        ...
    }
    
    public void print(int value) {
        ...
    }
    
    private void printNumber(short value) {
        ...
    }
    
    private void printNumber(char value) {
        ...
    }
}